<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客详情页</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/blog_detail.css">

    <!-- 引入 editor.md 的依赖 -->
    <link rel="stylesheet" href="editor.md/css/editormd.min.css" />
    <!-- <script src="js/jquery.min.js"></script> -->
    <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
    <!-- 先引入jquery 再引入editor.md依赖 -->
    <script src="editor.md/lib/marked.min.js"></script>
    <script src="editor.md/lib/prettify.min.js"></script>
    <script src="editor.md/editormd.js"></script>

</head>
<body>
    <div class="nav">
        <img src="img/login.jpg" alt="">
        <span class="title">我的博客系统</span>
    <!-- 此处的spacer只是用来占位，把后面的东西撑到右边去 -->
        <div class="spacer"></div>
        <a href="blog_list.html">主页</a>
        <a href="blog_edit.html">博客编辑页</a>
        <a href="logout">注销</a>
        <a href="#" id="delete">删除</a>
    </div>

   <!-- 左右排列的，就需要弹性布局 -->
   <!-- 页面的版心 -->
    <div class="container">
        <div class="container-left">
            <div class="card">
                <img src="img/ms.jpg" alt="">
                <h3>  </h3>
                <a href="#">gitub地址</a>
                <div class="counter">
                    <span>文章</span>
                    <span>分类</span>
                </div>
                <div class="counter">
                    <span>2</span>
                    <span>1</span>
                </div>
            </div>

        </div>
        <div class="container-right">
            <div class="blog-detail">
                <h3></h3>
                <div class="date"></div>
                <!-- id与下面markdown一致，opacity设置半透明效果 -->
                <div id="content" style="opacity: 80%">
                    <!-- 从今天起，我要好好学习，天天向上。
                    在现场VB那么，大法官好几年重新输入体育局内部
                    色的人同一个胡尽快
                    公寓及恐怕连套房源骨灰级哦
                    让对方太过于hi就OK骗了 -->
                    
                </p>
            </div>

        </div>
    </div>

    
    <!-- 引用jquery -->
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

    <!-- 检查登录状态 -->
    <script src="js/getLoginStatus.js"></script>
    
    <script>

        function getBlog(){
            $.ajax({
                type:'get',
                // 获取请求中的query string
                url:'blog'+ location.search,
                success:function(body){
                    // js 中组合用 >
                    let h3=document.querySelector('.blog-detail h3');
                    h3.innerHTML=body.title;
                    let dateDiv=document.querySelector('.date');
                    dateDiv.innerHTML=body.postTime;
                    // let contentDiv=document.querySelector('#content');
                    // contentDiv.innerHTML=body.content;

                    // 此处使用editor.md来渲染博客详情content
                    editormd.markdownToHTML('content',{markdown:body.content});

                }
            });
        }
        getBlog();

        //检查登录状态
        getLoginStatus();


        //详情页显示 文章作者的信息
        function getBlogUser(){
            $.ajax({
                type:'get',
                url:'userInfo'+location.search,
                success:function(body){
                    let username=document.querySelector(".container-left .card h3")
                    username.innerHTML=body.username;
                }
            });
        }
        getBlogUser();


        //页面加载时，给删除键的a标签设置好它的blogId
        function updateDeleteURL(){
            let deleteBlog=document.querySelector("#delete");
            deleteBlog.href="blog_delete"+location.search;

        }
        updateDeleteURL();

        

    </script>

    
</body>
</html>